package com.tristia.entity;

import java.util.Set;
import java.util.TreeSet;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.tristia.entity.util.ItemInfoIdComparator;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "reviews"
})
@XmlRootElement
public class Reviews {

    @XmlElement(name="review", required = true)
    protected Set<Review> reviews;

    public Reviews() {
		super();
		// TODO Auto-generated constructor stub
	}
    
    public Reviews(Set<Review> reviews) {
    	setReviews(reviews);
	}

	public Set<Review> getReviews() {
        if (reviews == null) {
        	reviews = new TreeSet<Review>(new ItemInfoIdComparator("ACS"));
        }
        return this.reviews;
    }

	public void setReviews(Set<Review> reviews) {
		this.reviews = reviews;
	}

	@Override
	public String toString() {
		return (this.reviews != null) ? "{\"reviews\": " + this.reviews.toString() + "}" : "{reviews:[]}";
	}
}
